package MyException;


public class Login {

    public String name = "zhangsan";
    public String password = "1008611";

    public void loginInFo(String name, String password) throws UserNameException, UserPassWordException {
        if(!(this.name.equals(name))) {
            throw new UserNameException();
        }

        if(!(this.password.equals(password))) {
            throw new UserPassWordException();
        }

        System.out.println("登陆成功");

    }

    public static void main(String[] args) {

        Login login = new Login();
        try {
            login.loginInFo("张三", "1008611");
        } catch(UserNameException e) {
            System.out.println("用户名错误");
        } catch(UserPassWordException e) {
            System.out.println("密码错误");
        }

    }
}



